/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = frct_detect_hash_key.c                             */
/*  NOTE      =                                                    */
/*  DATE      = 2016/04/20 by jikw                                 */
/*******************************************************************/
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "apmtest_comm.h"
#include "frct_detect_hash.h"

#define MODULE_L7PROTO     11211

extern int frct_detect_hash_key(u_short us_proto, char *p_key, unsigned int ui_key_size);

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void __case1(void)
{
    int i_ret = 0;
    char *p_key = NULL;
    
    i_ret = frct_detect_hash_key(MODULE_L7PROTO, p_key, 0);
    
    CU_ASSERT_EQUAL(i_ret, 0);

    return;
}

static void __case2(void)
{
    int i_ret = 0;
    char arr_key[10];
    
    i_ret = frct_detect_hash_key(MODULE_L7PROTO, arr_key, sizeof(arr_key));
    
    CU_ASSERT_EQUAL(i_ret, 2);

    return;
}

int add_suite_frct_detect_hash_key(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frct_comm frct_detect_hash_key()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);

    return FR_SUCC;
}
